package day23;

/**
 * 异常处理方式2   throws + 异常类型
 * @author yyfei
 *
 */
public class ThrowException {
	public static void main(String[] args) {
		
	}
	
	
	/**
	 * 直接在可能抛出异常的地方 加上 throws + 异常类型1，异常类型2
	 * @throws NumberFormatException
	 * @throws Exception
	 */
	public void test() throws NumberFormatException,Exception {
		String  str="123";
		str="abc";
		try {
			int num=Integer.parseInt(str);
		} catch(NumberFormatException e) {
			System.out.println(e.getMessage());
			//System.out.println("出现异常");
			e.printStackTrace();
			
		} catch (Exception e) {
			// TODO: handle exception
			e.getMessage();
			System.out.println("类型转换异常");
		}
		
		//System.out.println("继续执行");
	}
	
}
